//package com.qhong.generator;
//
//import com.baomidou.mybatisplus.generator.AutoGenerator;
//import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
//import com.baomidou.mybatisplus.generator.config.GlobalConfig;
//import com.baomidou.mybatisplus.generator.config.PackageConfig;
//import com.baomidou.mybatisplus.generator.config.StrategyConfig;
//import com.baomidou.mybatisplus.generator.config.rules.DbType;
//import com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;
//import org.junit.Test;
//
///**
// * Created by qhong on 2018/7/25 16:03
// **/
//public class GeneratorServiceEntity {
//
//	@Test
//	public void generateCode() {
//		String packageName = "com.qhong.modules";
//		boolean serviceNameStartWithI = false;//user -> UserService, 设置成true: user -> IUserService
//		generateByTables(serviceNameStartWithI, packageName, "users", "user_info","sys_role","sys_user_role");
//	}
//
//	private void generateByTables(boolean serviceNameStartWithI, String packageName, String... tableNames) {
//		GlobalConfig config = new GlobalConfig();
//		String dbUrl = "jdbc:mysql://127.0.0.1:3306/test1";
//		DataSourceConfig dataSourceConfig = new DataSourceConfig();
//		dataSourceConfig.setDbType(DbType.MYSQL)
//				.setUrl(dbUrl)
//				.setUsername("root")
//				.setPassword("111111")
//				.setDriverName("com.mysql.cj.jdbc.Driver");
//		StrategyConfig strategyConfig = new StrategyConfig();
//		strategyConfig
//				.setCapitalMode(true)
//				.setEntityLombokModel(false)
//				.setDbColumnUnderline(true)
//				.setNaming(NamingStrategy.underline_to_camel)
//				.setInclude(tableNames);//修改替换成你需要的表名，多个表名传数组
//		config.setActiveRecord(false)
//				.setAuthor("qhong")
//				.setOutputDir("src\\main\\java")
//				.setFileOverride(true);
//		if (!serviceNameStartWithI) {
//			config.setServiceName("%sService");
//		}
//		new AutoGenerator().setGlobalConfig(config)
//				.setDataSource(dataSourceConfig)
//				.setStrategy(strategyConfig)
//				.setPackageInfo(
//						new PackageConfig()
//								.setParent(packageName)
//								.setController("controller")
//								.setEntity("entity")
//				).execute();
//	}
//
//	private void generateByTables(String packageName, String... tableNames) {
//		generateByTables(true, packageName, tableNames);
//	}
//}
